package com.iot.ic.tcp.coder;

import com.iot.ic.tcp.model.MsgResponse;
import com.iot.ic.tcp.parse.DataPackage;
import com.iot.ic.tcp.utils.ByteUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

/**
 * 返回数据编码器
 * @author xiuge
 * 2016年10月28日上午8:36:07
 */
public class SendCustomEncoder extends MessageToByteEncoder<Object> {

	private Logger logger = LoggerFactory.getLogger(SendCustomEncoder.class);
	
	@Override
	protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
		MsgResponse response=(MsgResponse)msg;
		byte[] sentData= response.getDataBytes();
		out.writeBytes(sentData);
	}
}
